package com.huawei.billms.bills.controller;

import com.huawei.base.BaseRes;
import com.huawei.billms.bills.dto.BillsDto;
import com.huawei.billms.bills.entity.BillsEntity;
import com.huawei.billms.bills.service.BillsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 黄后林
 * @date 2022-11-04 15:32:10
 * @note 程序员是用代码喂出来的
 */
@RestController
@RequestMapping("bills")
public class BillsController {


    @Autowired
    private BillsService service;

    // http://localhost:8083/bills/list
    @GetMapping("list")
    public BaseRes  findAllBillsByConditions(BillsDto dto){

        List<BillsEntity> list = service.findAllBillsByConditions(dto);
        return BaseRes.getSuccess(list);

    }

    @PostMapping("save")
    public BaseRes  save( BillsEntity entity){

        Integer counter = service.save(entity);
        return BaseRes.getSuccess(counter);

    }
}
